<html>

<head>

</head>

<body>
    <script>
        // test
        const someAsyncThing = function() {
            return new Promise(function(resolve, reject) {
                // 下面一行会报错，因为x没有声明
                let x = 1;
                resolve(x + 2);
            });
        };

        someAsyncThing().finally(() => {
            console.log("finlly");
            return Promise.reject(4);
            // return Promise.resolve(4);
        }).catch(function(error) {
            console.log('oh no', error);
            return 6;
            return Promise.reject(7);
        }).then(function(n) {
            console.log('carry on', n);
            //return Promise.reject(11);
        }, (n) => {
            console.log("nonono", n);
            return 10;
        }).then(function(n) {
            console.log('carry on2', n);
        }, (n) => {
            console.log("nonono2", n);
        });
        // oh no [ReferenceError: x is not defined]
        // carry on
    </script>
</body>

</html>